package com.hbnu.test.www.net;

import java.io.*;
import java.net.Socket;
import java.net.UnknownHostException;

public class TCP_client04 {
    public static void main(String[] args) {
        try (Socket socket = new Socket("127.0.0.1", 6666);BufferedReader bufferedReader = new BufferedReader(new FileReader(new File("D:\\软件\\tmp\\class14.txt")));) {

            PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
            BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            String line = null;
            while((line = bufferedReader.readLine())!=null){
               out.println(line);
            }
//            out.println("over");
            socket.shutdownOutput();
            String result = in.readLine();
            System.out.println("文件上传结果：" + result);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
